#include <bits/stdc++.h>
using namespace std;

#define LOCAL

#ifdef LOCAL
template<typename T>
void err(T v) {
    cerr << v << endl;
}

void err() {
    cerr << endl;
}
template<typename T, typename... A>
void err(T v, A... args) {
    cerr << v << ", ";
    err(args...);
}
#define dbg(x...) { cerr << #x << " -> "; err(x);}

#else
#define dbg(...)

#endif

const int N = 2e5+50;
int n;
int a[N], b[N];
bool dat[N][3];

int main() {
    int t;
    scanf("%d", &t);
    for (int kk=0; kk<t; ++kk) {
        scanf("%d", &n);
        for (int i=1; i<=n; ++i) {
            scanf("%d", &a[i]);

            for (int j=0; j<3; ++j) {
                dat[i][j] = dat[i-1][j] | (a[i]+1 == j);
            }
        }
        for (int i=1; i<=n; ++i) {
            scanf("%d", &b[i]);
        }
        bool suc = true;
        for (int i=n; i>=1; --i) {
            if ((a[i] < b[i] && dat[i-1][2]) || (a[i] == b[i]) || (a[i] > b[i] && dat[i-1][0])) {

            } else {
                suc = false;
                break;
            }
        }

        if (suc)
            puts("YES");
        else
            puts("NO");

    }
    return 0;
}